CSharpTest.Net
ToArray Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : ToArray Method

Glossary Item Box

Returns this collection as an array

Syntax

Visual Basic (Declaration) 
Public Function ToArray() As T()
C# 
public T[] ToArray()

Example

Library/Library.Test/TestSetList.cs

C#Copy Code
SetList<string> list = new SetList<string>((IEnumerable<string>)new string[] { "a", "B" });
Assert.AreEqual("a,B", String.Join(",", list.ToArray())); 
            
list = new SetList<string>(2);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.Ordinal);
Assert.AreEqual("", String.Join(",", list.ToArray()));
list.Add("a");
list.Add("B");
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>(2, StringComparer.OrdinalIgnoreCase);
list.Add("a");
list.Add("B");
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));

list = new SetList<string>(new string[] { "B", "a" }, StringComparer.Ordinal);
Assert.AreEqual("B,a", String.Join(",", list.ToArray()));

list = new SetList<string>((IEnumerable<string>)new string[] { "B", "a" }, StringComparer.OrdinalIgnoreCase);
Assert.AreEqual("a,B", String.Join(",", list.ToArray()));
VB.NETCopy Code
Dim list As New SetList(Of String)(DirectCast(New String() {"a", "B"}, IEnumerable(Of String)))
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.Ordinal)
Assert.AreEqual("", [String].Join(",", list.ToArray()))
list.Add("a")
list.Add("B")
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(2, StringComparer.OrdinalIgnoreCase)
list.Add("a")
list.Add("B")
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(New String() {"B", "a"}, StringComparer.Ordinal)
Assert.AreEqual("B,a", [String].Join(",", list.ToArray()))

list = New SetList(Of String)(DirectCast(New String() {"B", "a"}, IEnumerable(Of String)), StringComparer.OrdinalIgnoreCase)
Assert.AreEqual("a,B", [String].Join(",", list.ToArray()))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys